//
// Created by 11510 on 2024/6/12.
//
#include <iostream>
using namespace std;

class FunctionObject{
public:

    /**
     * 第一个()是和operator连着一起作为函数名
     * 代表函数调用运算符进行重载
     * 第二个()是参数列表
     */
    void operator()(){
        _count++;
        cout << "operator()" << endl;
    }

    void operator()(int x){
        _count++;
        cout << "operator(int x)" << endl;
    }

    int operator()(int x, int y){
        _count++;
        cout << "operator(int x, int y)" << endl;
        return x + y;
    }

    int getCount(){
        return _count;
    }

private:
    int _count = 0;
};


void print(){
    printf("print()\n");
}

void test0(){
    FunctionObject functionObject;

    functionObject();
//    functionObject.operator()();
    functionObject(8);

    functionObject(7, 8);

    /**
     * 查看functionObject状态
     */
    cout << functionObject.getCount() << endl;
}

int main() {
    test0();
    return 0;
}